// task.js
// CREATE TABLE IF NOT EXISTS tasks (
//     id INTEGER PRIMARY KEY AUTOINCREMENT,
//     job_id INTEGER,
//     name TEXT,
//     status TEXT,
//     input TEXT,
//     output TEXT DEFAULT NULL, 
//     algo TEXT,
//     error TEXT DEFAULT NULL,
//     create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
//     update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
// )
class Task {
    constructor(taskId, jobId, name, input, algo) {
        this.id = taskId;
        this.job_id = jobId;
        this.name = name;
        this.status = 'pending'; // pending, running, completed, failed
        this.input = input;
        this.output = null;
        this.algo = algo;
        this.error = null;
    }

    start() {
        this.status = 'running';
    }

    complete(output) {
        this.status = 'completed';
        this.output = output;
    }

    fail(error) {
        this.status = 'failed';
        this.error = error;
    }
}

module.exports = { Task };
